package com.api.springdemo.service.impl;

import com.api.springdemo.entity.User;
import com.api.springdemo.dao.UserMapper;
import com.api.springdemo.service.UserService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User getById(int id){
        return userMapper.getById(id);
    }

    @Override
    @Transactional
    public void save(User hero){
        userMapper.saveUser(hero);
    }

    @Override
    public List<User> selectPage(Integer page,Integer size){
        PageHelper.startPage(page,size);
        return userMapper.selectPage();
    }


}
